from . import Blueprint, request, jsonify
from ..model.usr_mng_model import *

usr_mng = Blueprint('usr_mng', __name__)


@usr_mng.route('/addUser', methods=['POST'])
def add_user_req():
    # 新增用户
    name = request.get_json()['name']
    rmk = request.get_json()['rmk']
    return jsonify(add_user_do(name, rmk))


@usr_mng.route('/getUserList', methods=['POST'])
def get_user_list_req():
    # 获取用户列表
    name = request.get_json()['name']
    trasc_status = request.get_json()['trascStatus']
    page_num = request.get_json()['pageNum']
    return jsonify(get_user_list_do(name, trasc_status, page_num))


@usr_mng.route('/getUserDtl', methods=['POST'])
def get_user_dtl_req():
    # 获取用户详情
    name = request.get_json()['name']
    return jsonify(get_user_dtl_do(name))


@usr_mng.route('/updateUser', methods=['POST'])
def update_user_req():
    # 修改用户
    name = request.get_json()['name']
    rmk = request.get_json()['rmk']
    return jsonify(update_user_do(name, rmk))


@usr_mng.route('/deleteUser', methods=['POST'])
def delete_user_req():
    # 删除用户
    name = request.get_json()['name']
    return jsonify(delete_user_do(name))
